package robotStephane;

import javax.vecmath.Vector3d;

import simbad.gui.Simbatch;
import simbad.sim.Agent;
import simbad.sim.EnvironmentDescription;
import simbad.sim.RangeSensorBelt;
import simbad.sim.RobotFactory;

/**
 * @author buthane
 */
public class Robot extends Agent
{

	EnvironmentDescription	environment;
	RangeSensorBelt			sonars;

	private boolean			alive;
	
	public RangeSensorBelt getSonars()
	{
		return sonars;
	}
	
	public boolean isAlive()
	{
		return this.alive;
	}

	public Robot(Vector3d position, String name)
	{
		super(position, name);

		// Add sensors
		sonars = RobotFactory.addSonarBeltSensor(this, 8);
	}

	/** This method is called by the simulator engine on reset. */
	public void initBehavior()
	{
		this.alive = true;
	}

	/**
	 * This method is call cyclically (20 times per second) by the simulator
	 * engine.
	 */
	public void performBehavior()
	{
		this.alive = !collisionDetected();
	}

	public static void main(String[] args)
	{
		// request antialising
		System.setProperty("j3d.implicitAntialiasing", "false");
		// create Simbad instance with given environment
		Environnement env = new Environnement("simbad/resources/map1.png");
		//Simbad simbad = new Simbad(env, false);
		Simbatch simbatch = new Simbatch(env, true);
		
		simbatch.reset();
		for(int i = 0; i < 10000; i++)
		{
			simbatch.step();
		}
	}
}